home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / apps.to.go / DTS.Draw / TPieObj.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-05  |  14.9 KB  |  558 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** File:        TPieObj.c
  5. ** Written by:    Eric Soldan
  6. **
  7. ** Copyright © 1992-1993 Apple Computer, Inc.
  8. ** All rights reserved.
  9. */
  10.  
  11. /* You may incorporate this sample code into your applications without
  12. ** restriction, though the sample code has been provided "AS IS" and the
  13. ** responsibility for its operation is 100% yours.  However, what you are
  14. ** not permitted to do is to redistribute the source as "DSC Sample Code"
  15. ** after having made changes. If you're going to re-distribute the source,
  16. ** we require that you make it clear in the source that the code was
  17. ** descended from Apple Sample Code, but that you've made changes. */
  18.  
  19. /* See the files "=How to write your app" and "=Using TreeObj.c" for information
  20. ** on this function. */
  21.  
  22. /* This file implements the messages for the pie object.  Many of the messages
  23. ** can be handled by the rect object, as they deal with a rect structure.  Only
  24. ** a few of them are pie-specific. */
  25.  
  26. /* We have a custom hit-test handler here because there are additional sizing
  27. ** grabbers for the pie object.  The other objects just have grabbers at the
  28. ** corners.  A pie object also has grabber objects to adjust the "pie-slice". */
  29.  
  30.  
  31.  
  32. /*****************************************************************************/
  33.  
  34.  
  35.  
  36. #include "App.h"            /* Get the application includes/typedefs, etc.    */
  37. #include "App.protos.h"        /* Get the prototypes for the application.        */
  38.  
  39. #ifndef __OSEVENTS__
  40. #include <OSEvents.h>
  41. #endif
  42.  
  43. #ifndef __OSUTILS__
  44. #include <OSUtils.h>
  45. #endif
  46.  
  47. #ifndef __QUICKDRAW__
  48. #include <Quickdraw.h>
  49. #endif
  50.  
  51. #ifndef __STRING__
  52. #include <String.h>
  53. #endif
  54.  
  55. #ifndef __TREEOBJ2__
  56. #include "TreeObj2.h"
  57. #endif
  58.  
  59. #ifndef __UTILITIES__
  60. #include "Utilities.h"
  61. #endif
  62.  
  63.  
  64.  
  65. static OSErr    PieLayerProc(LayerObj theLayer, short message);
  66.  
  67.  
  68.  
  69. /*****************************************************************************/
  70.  
  71.  
  72.  
  73. #pragma segment DrawObjects
  74. long    TPieObj(TreeObjHndl hndl, short message, long data)
  75. {
  76.     ClickInfo    *click;
  77.     Rect        rct;
  78.     TreeObjHndl    hhndl;
  79.     RgnHandle    rgn, oldClip, newClip, accumRgn;
  80.     short        arcs, arcl, arcs2, arcl2, diff, i, angle, h, w;
  81.     Point        pt, where, curMouse;
  82.     long        flip, newSize;
  83.     LayerObj    pieLayer;
  84.     EventRecord    option;
  85.     RGBColor    rgb, rgb2;
  86. #if VH_VERSION
  87.     char        *cptr;
  88. #endif
  89.  
  90.     switch (message) {
  91.         case INITMESSAGE:
  92.             TRectObj(hndl, message, data);
  93.             mDerefPie(hndl)->arcStart  = 0;
  94.             mDerefPie(hndl)->arcLength = 360;
  95.             break;
  96.  
  97.         case FREEMESSAGE:
  98.         case COPYMESSAGE:
  99.         case UNDOMESSAGE:
  100.         case CONVERTMESSAGE:
  101.         case FREADMESSAGE:
  102.         case FWRITEMESSAGE:
  103.         case HREADMESSAGE:
  104.         case HWRITEMESSAGE:
  105.         case GETOBJRECTMESSAGE:
  106.         case SECTOBJRECTMESSAGE:
  107.         case KEYMESSAGE:
  108.         case SETSELECTMESSAGE:
  109.         case GETSELECTMESSAGE:
  110.         case COMPAREMESSAGE:
  111.             return(TRectObj(hndl, message, data));
  112.             break;
  113.  
  114.         case GETBBOXMESSAGE:
  115.             return(TLineObj(hndl, message, data));
  116.             break;
  117.  
  118.         case HITTESTMESSAGE:
  119.             click = (ClickInfo *)data;
  120.             hhndl = (TreeObjHndl)TRectObj(hndl, message, data);
  121.                 /* We must call TRectObj::HITTESTMESSAGE to set some static
  122.                 ** variables that TRectObj::SELECTOBJMESSAGE uses. */
  123.             if ((!hhndl) && (click->message == HITTESTGRABBER)) {
  124.                 if (mDerefRoot(GetRootHndl(hndl))->numSelected == 1) {
  125.                     if (mDerefPie(hndl)->selected) {
  126.                         rct   = mDerefPie(hndl)->arc;
  127.                         where = click->localEvent.where;
  128.                         InsetRect(&rct, -4, -4);
  129.                         if (PtInRect(where, &rct)) {
  130.                             GetMouse(&curMouse);
  131.                             for (i = 0; i < 2; ++i) {
  132.                                 pt = (i) ? mDerefPie(hndl)->arcEnd : mDerefPie(hndl)->arcBegin;
  133.                                 rct.bottom = (rct.top  = pt.v - 3) + 6;
  134.                                 rct.right  = (rct.left = pt.h - 3) + 6;
  135.                                 if (PtInRect(where, &rct)) {
  136.                                     click->localEvent.where = pt;
  137.                                     click->offset.h         = pt.h - curMouse.h;
  138.                                     click->offset.v         = pt.v - curMouse.v;
  139.                                     click->oldFlip          = 0;
  140.                                     click->newFlip          = 0;
  141.                                     click->grabber          = 5 + i;
  142.                                     hhndl = hndl;
  143.                                     break;
  144.                                 }
  145.                             }
  146.                         }
  147.                     }
  148.                 }
  149.             }
  150.             return((long)hhndl);
  151.             break;
  152.  
  153.         case GETRGNMESSAGE:
  154.             rgn      = NewRgn();
  155.             accumRgn = (RgnHandle)data;
  156.             if (accumRgn)
  157.                 if (GetHandleSize((Handle)accumRgn) > 10000)
  158.                     return((long)rgn);
  159.             NewLayer(&pieLayer, nil, PieLayerProc, nil, 0, (long)hndl);
  160.             if (pieLayer) {
  161.                 SetLayerWorld(pieLayer);
  162.                 TPieObj(hndl, DRAWMESSAGE, DRAWMASK);
  163.                 if (gQDVersion)
  164.                     BitMapToRegion(rgn, (BitMapPtr)(*((CGrafPtr)(*pieLayer)->layerPort)->portPixMap));
  165.                 else
  166.                     BitMapToRegion(rgn, &(*pieLayer)->layerPort->portBits);
  167.                 ResetLayerWorld(pieLayer);
  168.                 DisposeLayer(pieLayer);
  169.             }
  170.             if (accumRgn)
  171.                 UnionRgn(rgn, accumRgn, accumRgn);
  172.             return((long)rgn);
  173.             break;
  174.  
  175.         case SETOBJRECTMESSAGE:
  176.             TRectObj(hndl, message, data);
  177.             CalcPiePoints(hndl);
  178.             break;
  179.  
  180.         case DRAWMESSAGE:
  181.             rct = mDerefPie(hndl)->arc;
  182.             h   = mDerefCommon(hndl)->penHeight;
  183.             w   = mDerefCommon(hndl)->penWidth;
  184.             PenSize(w, h);
  185.             if (!EmptyRect(&rct)) {
  186.                 arcs = mDerefPie(hndl)->arcStart;
  187.                 arcl = mDerefPie(hndl)->arcLength;
  188.                 switch (data) {
  189.                     case DRAWOBJ:
  190.                         GetClip(oldClip = NewRgn());
  191.                         newClip = (RgnHandle)TOvalObj(hndl, GETRGNMESSAGE, 0);
  192.                         if (newClip)
  193.                             SetClip(newClip);
  194.                         if (gQDVersion)
  195.                             GetForeColor(&rgb);
  196.                         ForeColor(whiteColor);
  197.                         if (gQDVersion) {
  198.                             rgb2 = mDerefPie(hndl)->contentColor;
  199.                             RGBForeColor(&rgb2);
  200.                         }
  201.                         PaintArc(&rct, arcs, arcl);
  202.                         ForeColor(blackColor);
  203.                         if (gQDVersion) {
  204.                             rgb2 = mDerefPie(hndl)->borderColor;
  205.                             RGBForeColor(&rgb2);
  206.                         }
  207.                         FrameArc(&rct, arcs, arcl);
  208.                         pt = mDerefPie(hndl)->arcBegin;
  209.                         MoveTo(pt.h - (w / 2), pt.v - (w / 2));
  210.                         pt = mDerefPie(hndl)->center;
  211.                         LineTo(pt.h - (w / 2), pt.v - (w / 2));
  212.                         pt = mDerefPie(hndl)->arcEnd;
  213.                         LineTo(pt.h - (w / 2), pt.v - (w / 2));
  214.                         if (gQDVersion)
  215.                             RGBForeColor(&rgb);
  216.                         SetClip(oldClip);
  217.                         DisposeRgn(oldClip);
  218.                         if (newClip)
  219.                             DisposeRgn(newClip);
  220.                         break;
  221.                     case ERASEOBJ:
  222.                         EraseArc(&rct, arcs, arcl);
  223.                         break;
  224.                     case DRAWSELECT:
  225.                         if (mDerefPie(hndl)->selected) {
  226.                             TRectObj(hndl, message, data);
  227.                             for (i = 0; i < 2; ++i) {
  228.                                 pt = (i) ? mDerefPie(hndl)->arcEnd : mDerefPie(hndl)->arcBegin;
  229.                                 rct.bottom = (rct.top  = pt.v - 3) + 6;
  230.                                 rct.right  = (rct.left = pt.h - 3) + 6;
  231.                                 InvertRect(&rct);
  232.                                 arcl = mDerefPie(hndl)->arcLength;
  233.                                 if ((arcl == -360) || (!arcl) || (arcl == 360)) break;
  234.                             }
  235.                         }
  236.                         break;
  237.                     case DRAWGHOST:
  238.                         PenMode(patXor);
  239.                         FrameArc(&rct, arcs, arcl);
  240.                         break;
  241.                     case DRAWMASK:
  242.                         FillArc(&rct, arcs, arcl, (ConstPatternParam)&qd.black);
  243.                         FrameArc(&rct, arcs, arcl);
  244.                         pt = mDerefPie(hndl)->arcBegin;
  245.                         MoveTo(pt.h - (w / 2), pt.v - (w / 2));
  246.                         pt = mDerefPie(hndl)->center;
  247.                         LineTo(pt.h - (w / 2), pt.v - (w / 2));
  248.                         pt = mDerefPie(hndl)->arcEnd;
  249.                         LineTo(pt.h - (w / 2), pt.v - (w / 2));
  250.                         break;
  251.                 }
  252.             }
  253.             PenNormal();
  254.             break;
  255.  
  256.         case PRINTMESSAGE:
  257.             TPieObj(hndl, DRAWMESSAGE, DRAWOBJ);
  258.             break;
  259.  
  260. #if VH_VERSION
  261.         case VHMESSAGE:
  262.             cptr = ((VHFormatDataPtr)data)->data;
  263.             ccatchr(cptr, 13, 2);
  264.             ccat   (cptr, "$10: TPieObj:");
  265.             ccatchr(cptr, 13, 1);
  266.             ccat   (cptr, "  $00: selected = ");
  267.             ccatdec(cptr, mDerefPie(hndl)->selected);
  268.             ccatchr(cptr, 13, 1);
  269.             rct = mDerefPie(hndl)->arc;
  270.             ccat   (cptr, "  $02: pie      = (");
  271.             ccatdec(cptr, rct.top);
  272.             ccat   (cptr, ",");
  273.             ccatdec(cptr, rct.left);
  274.             ccat   (cptr, ",");
  275.             ccatdec(cptr, rct.bottom);
  276.             ccat   (cptr, ",");
  277.             ccatdec(cptr, rct.right);
  278.             ccat   (cptr, ")");
  279.             ccatchr(cptr, 13, 1);
  280.             ccat   (cptr, "  $0A: arcStart  = ");
  281.             ccatdec(cptr, mDerefPie(hndl)->arcStart);
  282.             ccatchr(cptr, 13, 1);
  283.             ccat   (cptr, "  $0C: arcLength = ");
  284.             ccatdec(cptr, mDerefPie(hndl)->arcLength);
  285.             ccatchr(cptr, 13, 1);
  286.             ccat   (cptr, "  $0E: center    = (");
  287.             ccatdec(cptr, mDerefPie(hndl)->center.v);
  288.             ccat   (cptr, ",");
  289.             ccatdec(cptr, mDerefPie(hndl)->center.h);
  290.             ccat   (cptr, ")");
  291.             ccatchr(cptr, 13, 1);
  292.             ccat   (cptr, "  $12: arcBegin  = (");
  293.             ccatdec(cptr, mDerefPie(hndl)->arcBegin.v);
  294.             ccat   (cptr, ",");
  295.             ccatdec(cptr, mDerefPie(hndl)->arcBegin.h);
  296.             ccat   (cptr, ")");
  297.             ccatchr(cptr, 13, 1);
  298.             ccat   (cptr, "  $16: arcEnd    = (");
  299.             ccatdec(cptr, mDerefPie(hndl)->arcEnd.v);
  300.             ccat   (cptr, ",");
  301.             ccatdec(cptr, mDerefPie(hndl)->arcEnd.h);
  302.             ccat   (cptr, ")");
  303.             ccatchr(cptr, 13, 1);
  304.             return(true);
  305.             break;
  306. #endif
  307.  
  308.         case CLICKMESSAGE:
  309.             TRectObj(hndl, message, data);
  310.             click = (ClickInfo *)data;
  311.             if (click->message == CLICKDRAG) {
  312.                 AddPt(click->offset, &mDerefPie(hndl)->center);
  313.                 AddPt(click->offset, &mDerefPie(hndl)->arcBegin);
  314.                 AddPt(click->offset, &mDerefPie(hndl)->arcEnd);
  315.             }
  316.             break;
  317.  
  318.         case SIZEMESSAGE:
  319.             click = (ClickInfo *)data;
  320.             if (click->grabber <= 4) {
  321.                 newSize = TRectObj(hndl, message, data);
  322.                 click = (ClickInfo *)data;
  323.                 flip = (click->oldFlip ^ click->newFlip);
  324.                 if (flip) {
  325.                     arcs = mDerefPie(hndl)->arcStart;
  326.                     arcl = mDerefPie(hndl)->arcLength;
  327.                     if (flip & VFLIPOBJ) {
  328.                         arcs -= (i = (arcs < 180) ? 0 : 180);
  329.                         arcs = 180 - arcs;
  330.                         arcl = -arcl;
  331.                         arcs += i;
  332.                     }
  333.                     if (flip & HFLIPOBJ) {
  334.                         arcs = 360 - arcs;
  335.                         arcl = -arcl;
  336.                     }
  337.                     mDerefPie(hndl)->arcStart  = arcs;
  338.                     mDerefPie(hndl)->arcLength = arcl;
  339.                 }
  340.                 CalcPiePoints(hndl);
  341.                 return(newSize);
  342.             }
  343.  
  344.             GetMouse(&curMouse);
  345.             curMouse.h += click->offset.h;
  346.             curMouse.v += click->offset.v;
  347.             rct = mDerefPie(hndl)->arc;
  348.  
  349.             arcs = arcs2 = mDerefPie(hndl)->arcStart;
  350.             arcl = arcl2 = mDerefPie(hndl)->arcLength;
  351.  
  352.             PtToAngle(&rct, curMouse, &angle);
  353.  
  354.             if (click->grabber == 6) {        /* Handle 2nd grabber as reverse first grabber case. */
  355.                 click->grabber = 5;
  356.                 arcs += arcl;
  357.                 arcl  = -arcl;
  358.                 while (arcs >  360) arcs -= 360;
  359.                 while (arcs <    0) arcs += 360;
  360.             }
  361.  
  362.             diff = angle - arcs;
  363.             arcs = angle;
  364.             OSEventAvail(nullEvent, &option);
  365.             if (!(option.modifiers & shiftKey)) {
  366.                 while (diff >  180) diff -= 360;        /* Force 1 change to be less than 180. */
  367.                 while (diff < -180) diff += 360;
  368.                 arcl   -= diff;
  369.                 while (arcl >  360) arcl -= 360;
  370.                 while (arcl < -360) arcl += 360;
  371.             }
  372.  
  373.             if ((arcs != arcs2) || (arcl != arcl2)) {
  374.                 mDerefPie(hndl)->arcStart  = arcs;
  375.                 mDerefPie(hndl)->arcLength = arcl;
  376.                 CalcPiePoints(hndl);
  377.                 return(true);
  378.             }
  379.             break;
  380.  
  381.         default:
  382.             break;
  383.     }
  384.  
  385.     return(noErr);
  386. }
  387.  
  388.  
  389.  
  390. /*****************************************************************************/
  391.  
  392.  
  393.  
  394. #pragma segment DrawObjects
  395. OSErr    CalcPiePoints(TreeObjHndl hndl)
  396. {
  397.     OSErr        err;
  398.     Rect        rct;
  399.     short        arcs, arcl, i, angle;
  400.     RgnHandle    rgn;
  401.     Point        pt;
  402.     long        ll;
  403.     LayerObj    pieLayer;
  404.  
  405.     err = NewLayer(&pieLayer, nil, PieLayerProc, nil, 0, (long)hndl);
  406.     if (err) return(err);
  407.  
  408.     rct  = mDerefPie(hndl)->arc;
  409.     arcs = mDerefPie(hndl)->arcStart;
  410.     arcl = mDerefPie(hndl)->arcLength;
  411.  
  412.     SetLayerWorld(pieLayer);
  413.     rgn = NewRgn();
  414.  
  415.     EraseRect(&rct);
  416.     FillArc(&rct, 90, 90, (ConstPatternParam)&qd.black);
  417.  
  418.     if (gQDVersion)
  419.         BitMapToRegion(rgn, (BitMapPtr)(*((CGrafPtr)(*pieLayer)->layerPort)->portPixMap));
  420.     else
  421.         BitMapToRegion(rgn, &(*pieLayer)->layerPort->portBits);
  422.     pt = *(Point *)(&(*rgn)->rgnBBox);
  423.     ll = PinRect(&rct, pt);
  424.     pt = *(Point *)≪
  425.     mDerefPie(hndl)->center = pt;
  426.  
  427.     for (i = 0; i < 2; ++i) {
  428.         angle = (i) ? (arcs + arcl) : (arcs);
  429.         while (angle < 0)    angle += 360;
  430.         while (angle >= 360) angle -= 360;
  431.         EraseRect(&rct);
  432.         if (angle < 90) {
  433.             FillArc(&rct, angle, 90, (ConstPatternParam)&qd.black);
  434.             if (gQDVersion)
  435.                 BitMapToRegion(rgn, (BitMapPtr)(*((CGrafPtr)(*pieLayer)->layerPort)->portPixMap));
  436.             else
  437.                 BitMapToRegion(rgn, &(*pieLayer)->layerPort->portBits);
  438.             pt.v = (*rgn)->rgnBBox.top;
  439.             EraseRect(&rct);
  440.             FillArc(&rct, angle, -90, (ConstPatternParam)&qd.black);
  441.             if (gQDVersion)
  442.                 BitMapToRegion(rgn, (BitMapPtr)(*((CGrafPtr)(*pieLayer)->layerPort)->portPixMap));
  443.             else
  444.                 BitMapToRegion(rgn, &(*pieLayer)->layerPort->portBits);
  445.             pt.h = (*rgn)->rgnBBox.right;
  446.             if (angle > 45)
  447.                 --pt.h;
  448.         }
  449.         if ((angle >= 90) && (angle < 180)) {
  450.             FillArc(&rct, angle, 90, (ConstPatternParam)&qd.black);
  451.             if (gQDVersion)
  452.                 BitMapToRegion(rgn, (BitMapPtr)(*((CGrafPtr)(*pieLayer)->layerPort)->portPixMap));
  453.             else
  454.                 BitMapToRegion(rgn, &(*pieLayer)->layerPort->portBits);
  455.             pt.h = (*rgn)->rgnBBox.right;
  456.             EraseRect(&rct);
  457.             FillArc(&rct, angle, -90, (ConstPatternParam)&qd.black);
  458.             if (gQDVersion)
  459.                 BitMapToRegion(rgn, (BitMapPtr)(*((CGrafPtr)(*pieLayer)->layerPort)->portPixMap));
  460.             else
  461.                 BitMapToRegion(rgn, &(*pieLayer)->layerPort->portBits);
  462.             pt.v = (*rgn)->rgnBBox.bottom;
  463.             if (angle < 135)
  464.                 --pt.h;
  465.             else
  466.                 --pt.v;
  467.         }
  468.         if ((angle >= 180) && (angle < 270)) {
  469.             FillArc(&rct, angle, 90, (ConstPatternParam)&qd.black);
  470.             if (gQDVersion)
  471.                 BitMapToRegion(rgn, (BitMapPtr)(*((CGrafPtr)(*pieLayer)->layerPort)->portPixMap));
  472.             else
  473.                 BitMapToRegion(rgn, &(*pieLayer)->layerPort->portBits);
  474.             pt.v = (*rgn)->rgnBBox.bottom;
  475.             EraseRect(&rct);
  476.             FillArc(&rct, angle, -90, (ConstPatternParam)&qd.black);
  477.             if (gQDVersion)
  478.                 BitMapToRegion(rgn, (BitMapPtr)(*((CGrafPtr)(*pieLayer)->layerPort)->portPixMap));
  479.             else
  480.                 BitMapToRegion(rgn, &(*pieLayer)->layerPort->portBits);
  481.             pt.h = (*rgn)->rgnBBox.left;
  482.             if (angle < 225)
  483.                 --pt.v;
  484.         }
  485.         if (angle >= 270) {
  486.             FillArc(&rct, angle, 90, (ConstPatternParam)&qd.black);
  487.             if (gQDVersion)
  488.                 BitMapToRegion(rgn, (BitMapPtr)(*((CGrafPtr)(*pieLayer)->layerPort)->portPixMap));
  489.             else
  490.                 BitMapToRegion(rgn, &(*pieLayer)->layerPort->portBits);
  491.             pt.h = (*rgn)->rgnBBox.left;
  492.             EraseRect(&rct);
  493.             FillArc(&rct, angle, -90, (ConstPatternParam)&qd.black);
  494.             if (gQDVersion)
  495.                 BitMapToRegion(rgn, (BitMapPtr)(*((CGrafPtr)(*pieLayer)->layerPort)->portPixMap));
  496.             else
  497.                 BitMapToRegion(rgn, &(*pieLayer)->layerPort->portBits);
  498.             pt.v = (*rgn)->rgnBBox.top;
  499.         }
  500.         ll = PinRect(&rct, pt);
  501.         pt = *(Point *)≪
  502.         (i) ? (mDerefPie(hndl)->arcEnd = pt) : (mDerefPie(hndl)->arcBegin = pt);
  503.     }
  504.  
  505.     DisposeRgn(rgn);
  506.     ResetLayerWorld(pieLayer);
  507.     DisposeLayer(pieLayer);
  508.     return(noErr);
  509. }
  510.  
  511.  
  512.  
  513. /*****************************************************************************/
  514.  
  515.  
  516.  
  517. static OSErr    PieLayerProc(LayerObj theLayer, short message)
  518. {
  519.     OSErr        err;
  520.     TreeObjHndl    pie;
  521.     Rect        rct;
  522.     CGrafPtr    keepPort;
  523.     GDHandle    keepGDevice;
  524.     GWorldPtr    layerWorld;
  525.  
  526.     switch (message) {
  527.         case kLayerInit:
  528.             err = noErr;
  529.             if (theLayer) {
  530.                 if (!(*theLayer)->layerPort) {
  531.                     pie = (TreeObjHndl)(*theLayer)->layerData;
  532.                     rct = mDerefPie(pie)->arc;
  533.                     GetGWorld(&keepPort, &keepGDevice);        /* Keep the GWorld. */
  534.                     err = NewGWorld(&layerWorld, 1, &rct, nil, nil, 0);
  535.                     if (err == noErr) {
  536.                         (*theLayer)->layerOwnsPort = true;
  537.                         SetPort((*theLayer)->layerPort = (GrafPtr)layerWorld);
  538.                         SetOrigin(rct.left, rct.top);
  539.                         EraseRect(&rct);
  540.                     }
  541.                     SetGWorld(keepPort, keepGDevice);        /* Restore the kept GWorld. */
  542.                 }
  543.             }
  544.             else err = paramErr;
  545.             break;
  546.  
  547.         default:
  548.             err = DefaultLayerProc(theLayer, message);
  549.                 /* Default behavior for everything else. */
  550.             break;
  551.     }
  552.  
  553.     return(err);
  554. }
  555.  
  556.  
  557.  
  558.